<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>知识库</title>
    <t:base type="ckeditor,jquery,easyui,tools,DatePicker"></t:base>
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
    <script type="text/javascript">

        $(function () {
            loadTree();
        });
        function loadTree(plazaName) {
            rightTree = $("#tree").tree({
                url: "zyEmValidaRuleController.do?dataGridOfChooseEquipmentType",
                checkbox: true,
                onLoadSuccess : function(node) {
                    var protypeIds = $("#protypeId").val();
                    /*console.log("protypeIds--:"+protypeIds);*/
                    var protypeArr = protypeIds.split(",");
                    /*已勾选的id*/
                     $.each(protypeArr,function(idx,itm){
                        var node = $("#tree").tree("find",itm);
                        if(node != undefined && node.target != undefined){
                            $("#tree").tree("check",node.target);
                        }
                     })
                     /*//不被选中
                     $.each(noEffProtypeIdArr,function(idx,itm){
                     var node = $("#tree").tree("find",itm);
                     if(node != undefined && node.target != undefined){
                     $("#tree").tree("uncheck",node.target);
                     }
                     })*/
                }
            });
        }

        function jiaoyan() {
            var value = $("#knowLedgeType option:selected").attr("value");
            /*alert(value);*/
            if (value == "") {
                alert("请选择类别！");
                return false;
            }
            var node = $('#tree').tree('getChecked');
            var cnodeIds = '';
            var cnodeValues = '';
            for ( var i = 0; i < node.length; i++) {
                cnodeIds += node[i].id + ',';
                cnodeValues += node[i].text + ',';
            }
            cnodeIds = cnodeIds.substring(0, cnodeIds.length - 1);
            cnodeValues = cnodeValues.substring(0, cnodeValues.length - 1);
            /*console.log("length--:"+node.length);
            console.log("cnodeIds--:"+cnodeIds);
            console.log("cnodeValues--:"+cnodeValues);*/
            $("#zyEsitemIds").val(cnodeIds);
            $("#zyEsItem").val(cnodeValues);
        }

    </script>
</head>
<body>
<t:formvalid formid="formobj" dialog="true" layout="table" action="cbsAppKnowledgeController.do?doAdd" tiptype="3"
             beforeSubmit="jiaoyan">
    <table style="width: 100%;" cellpadding="0" cellspacing="1" class="formtable">
        <tr>
            <td align="right" style="width:70px;">
                <label class="Validform_label">
                    编号:
                </label>
            </td>
            <td class="value">
                <input id="no" name="no" type="text" style="width: 200px" class="inputxt" datatype="*1-20"/>
                <span class="Validform_checktip"></span>
                <label class="Validform_label" style="display: none;">编号</label>
            </td>
        </tr>
        <tr>
            <td align="right">
                <label class="Validform_label">
                    标题:
                </label>
            </td>
            <td class="value">
                <input id="title" name="title" type="text" style="width: 300px" class="inputxt" datatype="*1-100"/>
                <span class="Validform_checktip"></span>
                <label class="Validform_label" style="display: none;">标题</label>
            </td>
        </tr>
        <tr>
            <td align="right">
                <label class="Validform_label">
                    类别:
                </label>
            </td>
            <td class="value">
				<span>
					<select name="knowLedgeType" id="knowLedgeType" style="width: 200px" datatype="*1-100">
						<option value="">---请选择--- </option>
						<c:forEach items="${dataList }" var="depart">
                            <option value="${depart.typecode }">${depart.typename }</option>
                        </c:forEach>
					</select>
				</span>
                <span class="Validform_checktip"></span>
                <label class="Validform_label" style="display: none;">类别</label>
            </td>
        </tr>
        <tr>
            <td align="right">
                <label class="Validform_label">
                    适用机型:
                </label>
            </td>
            <td class="value">
                <input name="zyEsitemIds" type="hidden" id="zyEsitemIds" />
                <input name="zyEsItem" type="hidden" id="zyEsItem" />
                <input type="hidden" id="protypeId" value="${cbsAppKnowledgePage.zyEsitemIds}"/>
                <div region="center" style="padding: 1px;height: 150px;overflow-y: auto;">
                    <div id="tree"></div>
                </div>
            </td>
        </tr>
        <tr>
            <td align="right"><label class="Validform_label"> 可见<t:mutiLang langKey="common.role"/>: </label></td>
            <td class="value" nowrap>
                <input name="roleid" type="hidden" value="${id}" id="roleid" >
                <input name="roleName" class="inputxt" style="width: 300px" value="${roleName }" id="roleName" readonly="readonly" datatype="*" nullmsg="请选择角色"/>
                <t:choose hiddenName="roleid" hiddenid="id" url="userController.do?roles" name="roleList"
                          icon="icon-search" title="common.role.list" textname="roleName" isclear="true" height="500px" width="400px"/>
                <span class="Validform_checktip"><t:mutiLang langKey="role.muti.select"/></span>
            </td>
        </tr>

        <tr>
            <td align="right">
                <label class="Validform_label">
                    内容:
                </label>
            </td>
            <td class="value">
                <textarea style="width:'100%';height:270px;" class="inputxt" rows="6" id="content" name="content"
                          maxlength="3300" datatype="*"></textarea>
                <span class="Validform_checktip"></span>
                <label class="Validform_label" style="display: none;">内容</label>
            </td>
        </tr>
    </table>
</t:formvalid>
</body>
<script type="text/javascript" src="webpage/com/app/cbs_app_knowledge/cbsAppKnowledge-add.js"></script>